package com.markby.fscm.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.markby.fscm.domain.RecordLog;
import com.markby.fscm.domain.RecordLogEnum;
import com.markby.fscm.service.RecordLogService;
import com.markby.fscm.mapper.RecordLogMapper;
import com.markby.fscm.utils.IpUtils;
import org.springframework.stereotype.Service;

import java.util.Date;

import static com.markby.fscm.utils.DateFormatUtils.formatDate;

/**
 * @author baoyu
 * @description 针对表【record_log】的数据库操作Service实现
 * @createDate 2024-08-11 11:01:27
 */
@Service
public class RecordLogServiceImpl extends ServiceImpl<RecordLogMapper, RecordLog>
        implements RecordLogService {

    @Override
    public void record(RecordLogEnum recordLogEnum, String source) {
        RecordLog recordLog = new RecordLog();
        recordLog.setIp(IpUtils.getIpAddr());
        recordLog.setOperation(recordLogEnum.getOperation());
        recordLog.setState(recordLogEnum.getState());
        recordLog.setMsg(recordLogEnum.getMessage());
        recordLog.setTime(formatDate(new Date()));
        recordLog.setSource(source);

        baseMapper.insert(recordLog);
    }
}




